<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{$activityname}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
<link href="{$Think.config.RESOURCEURL}wx_assets/vote/vote.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
</head>
<body class="bg-common" >
<div style="background-image:url({$jsonstr.COMMON_BACKGROUND_OTHER.src});min-height: 100%;background-size: 100% 100%;background-position: top;width: 100%;">
    <a class="bg-common bg_zjt" href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=vote&method=index&params=%7B%22actId%22%3A%22{$actId}%22%7D' style="background-image:url({$jsonstr.COMMON_BUTTON_BACK.src})"></a>
    <div class="reg-zhuti">
        <img src="{$jsonstr.BAOMING_ZHUTI.src}">
    </div>
    <div class="reg-box" id="regBox">
        <dl>
            <dt>
                <img src="{$jsonstr.BAOMING_LABEL_XINGMING.src}@100sh.png" >
            </dt>
            <dd>
                <input type="text" value="{$regInfo.name}" class="txt" id="name" maxlength="4"/>
            </dd>
        </dl>
        <dl>
            <dt>
                <img src="{$jsonstr.BAOMING_LABEL_LIANXI.src}@100sh.png" >
            </dt>
            <dd>
                <input type="text" value="{$regInfo.phone}" class="txt" id="phone"/>
            </dd>
        </dl>
        <dl>
            <dt>
                <img src="{$jsonstr.BAOMING_LABEL_WEIXIN.src}@100sh.png" >
            </dt>
            <dd>
                <input type="text" value="{$regInfo.weixin}" class="txt" id="weixin"/>
            </dd>
        </dl>
        <dl>
            <dt style="width: 100%;position: relative;">
                <img src="{$jsonstr.BAOMING_LABEL_SHANGCHUAN.src}@100sh.png" >
            </dt>
            <dd id="zuopin" style="margin: 5px 0;">
                <if condition="$regInfo.picurl neq ''">
                    <volist name="regInfo.picurl" id="picurl">
                        <img class="zuopinimg" data-img="{$picurl}" src="{$picurl}@70w_70h_1e_1c_2o_1sh.jpg">
                    </volist>
                 <else/>
                    <div class="upload" id="upload">
                    </div>
                </if>
            </dd>
        </dl>
        <a class="bg-common tijiao js-btn" id="BtnSave" data-normal="{$jsonstr.BAOMING_BUTTON_TIJIAO_NORMAL.src}" data-click="{$jsonstr.BAOMING_BUTTON_TIJIAO_CLICK.src}" style="background-image:url({$jsonstr.BAOMING_BUTTON_TIJIAO_NORMAL.src})">&nbsp;</a>
        <img id="BAOMING_BUTTON_TIJIAO_CLICK" src="{$jsonstr.BAOMING_BUTTON_TIJIAO_CLICK.src}" style="display:none">
    </div>
</div>
<script>
var baseUrl = '{$Think.config.SERVER_HOST}';
var page={
    init:function(){
        this.initButtonState();
        this._initEvent();
        this._initValidate();
    },
    initButtonState:function(){
        $(".js-btn").tap(function(){
            var clickUrl=$(this).data("click");
            var normalUrl=$(this).data("normal");
            var me=this;
            $(this).css("background-image","url("+clickUrl+")");
            setTimeout(function(){
                $(me).css("background-image","url("+normalUrl+")");
            },100);
        });
    },
    _initEvent:function(){
        var me=this;
        $("#upload").click(function(){
            wx_share.uploadImage(function(data){
                $("#zuopin").prepend(
                    "<img class='zuopinimg' data-img='"+data.path+"' src='"+data.path+"@70w_70h_1e_1c_2o_1sh.jpg'/>"
                );

                if($("#zuopinimg").length>=3){
                    $("#upload").hide();
                }
            });
        });
    },
    _initValidate:function(){
     var me = this;
     var config = {};
     config = {
            "name":{
                rule: {
                    required: {
                        message: "请输入姓名"
                    }
                },
                pos: "bottom"
            },
            "phone": {
                rule: {
                    required: {
                        message: "请输入11位手机号码！"
                    },
                    mobile: {
                        message: "请输入11位手机号码！"
                    }
                },
                pos: "bottom"
            },
             "weixin": {
                 rule: {
                     required: {
                         message: "请输入微信号！"
                     }
                 },
                 pos: "bottom"
             },
            "zuopin_hide":{
                rule: {
                    required: {
                        message: "请上传作品"
                    }
                },
                pos: "bottom",
                x:115,
                y:73
            }
        }
        var va = new Validate("regBox", config);
        $("#BtnSave").click(function() {
            va.validate(function(result) {
                if (result) {
                    me._save();
                }
            });
        });
    },
    _save:function(){
        var img = new Array(0);
        $(".zuopinimg").each(function(){
            img.push($(this).data("img"));
        });
        var p=$.util.getParamAsObject();
        $.req.get("call.json?module=vote&customerId={$customerId}&method=saveReg",{
            userName:"{$userName}",
            params:{
                "name":$("#name").val(),
                "phone":$("#phone").val(),
                "picurl":img.join(","),
                "weixin":$("#weixin").val(),
                "qId":p.qId,
                "miUId":p.miUId,
                "id":"{$regInfo.id}",
                "actId":"{$actId}",
                "sId":"{$sId}"
            }
        },function(data){
            if(!data.code){
               var params={
                    "id":data.id,
                    "actId":"{$actId}"
                }
                params=encodeURIComponent(JSON.stringify(params));
                location.href= 'call.html?customerId={$customerId}&module=vote&method=detail&params='+params;
            } else {
                $.util.alert(data.msg);
            }
        });
    },
    getShareUrl:function(){
        var p=$.util.getParamAsObject();
        var shareUrl="";
        var params={
            "qId":"{$qId}",
            "fromUId":"{$fromUId}"
        };
        params=encodeURIComponent(JSON.stringify(params));
        shareUrl=baseUrl+'call.html?customerId={$customerId}&module=quan&scope=1&method=index&params='+params;
        return shareUrl;
    }
}
page.init();
var shareUrl=page.getShareUrl();
wx_share.init({
    "title":"{$title}",
    "desc":'{$description}',
    "link":shareUrl,
    "imgUrl":"{$picurl}",
    "pkg":{
        "appId": '{$pkg.appId}',
        "timestamp": {$pkg.timestamp},
        "nonceStr": '{$pkg.nonceStr}',
        "signature": '{$pkg.signature}'
    },
    success:function(config,shareType){
        
    }
 });
</script>
</body>
</html>